package com.example.demo.controller;

import io.swagger.annotations.Api;
import net.coobird.thumbnailator.Thumbnails;
import org.apache.catalina.connector.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;


/**
 *  .size()     指定大小
 *  .rotate(90) 旋转
 *  .scale(1f)  指定比列
 *  .outputQuality(0.5f)  压缩质量
 *  .sourceRegion  裁剪
 *  .watermark(位置，水印图，透明度)    watermark( Positions.CENTER,ImageIO.read(new File("D://样本//岛上的女孩.jpg")), 0.5f)
 *  .outputFormat(图像格式) 转换图像格式
 *  .toOutputStream(流对象)
 */

@RestController
@Api(tags = "图片处理入口")
@RequestMapping("/image")
public class ImageController {

    private static final Logger log = LoggerFactory.getLogger(ImageController.class);

    @GetMapping("/compressedImage")
    public boolean compressedImage() throws IOException {

        log.info(System.getProperty("os.name"));
        //linux
        if(System.getProperty("os.name").toLowerCase().contains("linux")){

        }else if(System.getProperty("os.name").toLowerCase().contains("windows")){
                //windows

        }
        Thumbnails.of("C:\\Users\\火箭\\Desktop\\表情包\\小老弟，你有问题.gif").scale(0.9)
                .toFile("C:\\Users\\火箭\\Desktop\\表情包\\小老弟，你有问题1111.gif");


        return true;
    }
}
